﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECONTACT.DataLayer
{
    public class HocLucData
    {
        DataService m_HocLucData = new DataService();

        public DataTable LayDShHocLuc()
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM HOCLUC");
            m_HocLucData.Load(cmd);
            return m_HocLucData;
        }

        public void LuuHocLuc(String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_ThemHocLuc");

            cmd.Parameters.Add("@TenHocLuc", SqlDbType.NVarChar).Value = Ten;

            m_HocLucData.LoadProc(cmd);
        }

        public void UpdateHocLuc(String MaHL, String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_CapNhatHocLuc");

            cmd.Parameters.Add("@MaHocLuc", SqlDbType.NVarChar).Value = MaHL;
            cmd.Parameters.Add("@TenHocLuc", SqlDbType.NVarChar).Value = Ten;

            m_HocLucData.LoadProc(cmd);
        }

        public void DeleteHocLuc(String MaHL)
        {
            SqlCommand cmd = new SqlCommand("sp_XoaHocLuc");

            cmd.Parameters.Add("@MaHocLuc", SqlDbType.Int).Value = Convert.ToInt32(MaHL);

            m_HocLucData.LoadProc(cmd);
        }
    }
}
